<!DOCTYPE html>
<html lang="ch" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="utf-8">
    <title>Category类型</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" th:href="@{/lib/layui-v2.6.3/css/layui.css}" media="all">
    <link rel="stylesheet" th:href="@{/css/public.css}" media="all">
</head>
<body>
<div class="layui-form layuimini-form">
    <div class="layui-form-item">
        <label class="layui-form-lable">Item所属商品</label>
        <div class="layui-form-block">
            <input type="text" name="productId" disabled="disabled" th:placeholder="${productId}" th:value="${productId}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">具体ItemID</label>
        <div class="layui-input-block">
            <input type="text" name="itemId" lay-verify="required" lay-reqtext="ID不能为空" placeholder="请输入ItemID" value="" class="layui-input">
            <tip>填写ItemID</tip>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">具体Item售价</label>
        <div class="layui-input-block">
            <input type="text" name="listPrice" lay-verify="required" lay-reqtext="售价不能为空" placeholder="请输入Item售价" value="" class="layui-input">
            <tip>填写商品售价</tip>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">具体Item进价</label>
        <div class="layui-input-block">
            <input type="text" name="unitCost" lay-verify="required" lay-reqtext="进价不能为空" placeholder="请输入Item进价" value="" class="layui-input">
            <tip>填写商品进价</tip>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">具体Item供货商</label>
        <div class="layui-input-block">
            <input type="text" name="supplierId" lay-verify="required" lay-reqtext="供货商不能为空" placeholder="请输入Item供货商" value="" class="layui-input">
            <tip>填写商品供货商(1或者2)</tip>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">Item是否上架</label>
        <div class="layui-input-block">
            <input type="text" name="status" lay-verify="required" lay-reqtext="是否上架" placeholder="请输入Item状态" value="" class="layui-input">
            <tip>填写商品货架状态</tip>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">具体Item介绍（1）</label>
        <div class="layui-input-block">
            <input type="text" name="attr1" lay-verify="" lay-reqtext="请输入Item介绍" placeholder="请输入Item介绍" value="" class="layui-input">
            <tip>填写商品介绍</tip>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">具体Item介绍（2）</label>
        <div class="layui-input-block">
            <input type="text" name="attr2" lay-verify="" lay-reqtext="请输入Item介绍" placeholder="请输入Item介绍" value="" class="layui-input">
            <tip>填写商品介绍</tip>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">具体Item介绍（3）</label>
        <div class="layui-input-block">
            <input type="text" name="attr3" lay-verify="" lay-reqtext="请输入Item介绍" placeholder="请输入Item介绍" value="" class="layui-input">
            <tip>填写商品介绍</tip>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">具体Item介绍（4）</label>
        <div class="layui-input-block">
            <input type="text" name="attr4" lay-verify="" lay-reqtext="请输入Item介绍" placeholder="请输入Item介绍" value="" class="layui-input">
            <tip>填写商品介绍</tip>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">具体Item介绍（5）</label>
        <div class="layui-input-block">
            <input type="text" name="attr5"  lay-reqtext="请输入Item介绍" placeholder="请输入Item介绍" value="" class="layui-input">
            <tip>填写商品介绍</tip>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn" >确认保存</button>
        </div>
    </div>
</div>
<script src="/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script src="/js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script>
    layui.use(['form','miniTab'], function () {
        var form = layui.form,
            layer = layui.layer,
            miniTab = layui.miniTab;

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            var url = window.location.href;
            var xhr = new XMLHttpRequest();
            var json = JSON.stringify(data.field)
            var index = layer.alert(json, {
                title: '最终的提交信息'
            }, function () {
                xhr.open("POST",url,true);
                xhr.setRequestHeader("Content-Type","application/json");
                xhr.send(json);
                xhr.onreadystatechange = function () {
                    if(xhr.status == 4){
                        if(xhr.readyState == 200||xhr.readyState == 304){
                            window.alert('114');
                        }
                    }
                }
                layer.close(index);
                // layer.msg(data.msg,{icon:1,time:500},function(){
                //     setTimeout('window.location.load()',500);
                // });
                layer.msg(data.msg, {icon:1,time:200}, function(){
                    var index = parent.layer.getFrameIndex(window.name);
                    parent.location.reload(); //刷新父页面
                    parent.layer.close(index);
                });

            });
            return false;
        });

    });

</script>
</body>
</html>